//----------------------------------------------------------
//
//   SA:MP Multiplayer Modification For GTA:SA
//   Copyright 2004-2007 SA:MP Team
//
//----------------------------------------------------------



#ifndef NULL
 #define NULL (0)
#endif


#define PP_CAT_0(a,b) a ## b
#define PP_CAT(a,b) PP_CAT_0(a, b)

#define PP_STR_0(a) #a
#define PP_STR(a) PP_STR_0(a)


#define PREFIX /* extern "C" */
#define NATIVE_DECL(fn) PREFIX static cell AMX_NATIVE_CALL PP_CAT(n_, fn)

#define ARRAY_DECL(fn) { PP_STR(fn), PP_CAT(n_, fn) }
#define MYARRAY_DECL(fn) { PP_STR(PP_CAT(my, fn)), PP_CAT(n_, fn) }


#define _CRT_SECURE_NO_WARNINGS 1
//#include <malloc.h> // alloca error fix

#include "SDK/plugin.h"

#include <cstdio>

#include <cmath>
#include <cstring>


// stl
#include <list>



#define PI 3.14159265


#include "funcs.inl"
#include "memory.inl"
#include "yfiles.inl"

#ifdef BINDS_H

NATIVE_DECL(add_bind) (AMX *amx, cell *params)
{ // int playerid, int key, char *cmd
	int playerid = params[1], key = params[2];
	char *cmd;
	amx_StrParam(amx, params[3], cmd);
	return add_bind(playerid, key, cmd);
}

NATIVE_DECL(check_binds) (AMX *amx, cell *params)
{ // int playerid, int newkeys, int oldkeys
	return check_binds(params[1], params[2], params[3]);
}
NATIVE_DECL(del_bind) (AMX *amx, cell *params)
{
	return del_bind(params[1], params[2]);
}

NATIVE_DECL(bound_bind) (AMX *amx, cell *params)
{
	return binds_bound();
}
NATIVE_DECL(get_bind) (AMX *amx, cell *params)
{
	cell *playerid, *keys, *ccmd;
	std::string cmd;
	amx_GetAddr(amx, params[2], &playerid);
	amx_GetAddr(amx, params[3], &keys);
	bool res =
		get_bind_by_index(params[1], (int *)playerid, (int *) keys, cmd);
	if(res)
	{
		amx_GetAddr(amx, params[4], &ccmd);
		amx_SetString(ccmd, cmd.c_str(), 0, 0, params[5]);
	}
	return res;
}


#endif



/************************************************ AMX **************************************************/


// And an array containing the native function-names and the functions
// specified with them, e.g. HelloWorld -> n_HelloWorld in this example.



AMX_NATIVE_INFO natives[ ] =
{
	//ARRAY_DECL(mystrstart),
	MYARRAY_DECL(strend),
	MYARRAY_DECL(strtok),
	MYARRAY_DECL(stricmp),
	
	MYARRAY_DECL(getxy),
	MYARRAY_DECL(scrash),
//	MYARRAY_DECL(srand),
	MYARRAY_DECL(rand),
	MYARRAY_DECL(sendplayercmd),
	MYARRAY_DECL(command),
	MYARRAY_DECL(getsyst),

	MYARRAY_DECL(peek),
	MYARRAY_DECL(poke),
	MYARRAY_DECL(addr_global),

#ifdef BINDS_H
	ARRAY_DECL(bind_add),
	ARRAY_DECL(bind_check_all),
	ARRAY_DECL(bind_remove),
	ARRAY_DECL(bind_upper_bound),
	ARRAY_DECL(bind_get),
#endif
	
	// File
	ARRAY_DECL(ffind),
	ARRAY_DECL(frename),

	// Directory
	ARRAY_DECL(dfind),
	ARRAY_DECL(dcreate),
	ARRAY_DECL(drename),

	{ 0, 0 }
};

#include "plugin.inl"

